﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.examstu
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int esId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(esId);
				}
			}
		}
			
	private void ShowInfo(int esId)
	{
		Maticsoft.BLL.examstu bll=new Maticsoft.BLL.examstu();
		Maticsoft.Model.examstu model=bll.GetModel(esId);
		this.lblesId.Text=model.esId.ToString();
		this.txtexamRoomId.Text=model.examRoomId.ToString();
		this.txtstuId.Text=model.stuId.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtexamRoomId.Text))
			{
				strErr+="考场ID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtstuId.Text))
			{
				strErr+="学生ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int esId=int.Parse(this.lblesId.Text);
			int examRoomId=int.Parse(this.txtexamRoomId.Text);
			int stuId=int.Parse(this.txtstuId.Text);


			Maticsoft.Model.examstu model=new Maticsoft.Model.examstu();
			model.esId=esId;
			model.examRoomId=examRoomId;
			model.stuId=stuId;

			Maticsoft.BLL.examstu bll=new Maticsoft.BLL.examstu();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
